<?php
/**
 * Created by PhpStorm.
 * User: xing
 * Date: 2018/11/21
 * Time: 4:09 PM
 */
namespace app\wechat\controller;

use app\common\service\Customer;
use app\common\service\Stock;

trait WechatTrait {

    /**
     * 用户基础信息返回
     * @param null $customer
     * @return mixed
     */
    public function baseCustomerInfo($customer = null) {

        $currentCustomer = $this->request->currentCustomer;

        // 如果 customer实体不为空
        if (!isNullOrEmpty($customer)) {
            $currentCustomer = $customer;
        }

        $returnData['nickname'] = strExceedingLength($currentCustomer['nickname']);
        $returnData['headimgurl'] = $currentCustomer['headimgurl'];
        $returnData['background_image'] = $currentCustomer['background_image'];
        $returnData['history_point'] = $currentCustomer['history_point'];
        $returnData['total_point'] = $currentCustomer['total_point'];
        $returnData['sign'] = $currentCustomer['sign'];
        $returnData['current_level'] = $currentCustomer['current_level'];
        $returnData['vip'] = $currentCustomer['vip'];
        $returnData['newest_like_list'] = json_decode(
            $currentCustomer['newest_like_json'], true);

        return $returnData;

    }

}